package com.ssh.action;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.service.IStudentService;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;

@Controller
@Scope("prototype")
public class StudentAction extends ActionSupport {

    @Resource(name = "studentService")
    private IStudentService studentService;

    // 显示一个学生数据
    public String showStudent() {
        // 把结果保存到request域中
        ServletActionContext.getRequest().setAttribute("student", studentService.findById(1));
        return SUCCESS;
    }
}